﻿<%@ Page Title="" Language="C#" MasterPageFile="ReconSite.Master" AutoEventWireup="true"
    CodeBehind="UserMaster.aspx.cs" Inherits="Recon.Portal.WebUI.UserMaster" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleHolder" runat="server">
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="BodyHolder" runat="server">
     <div class="formDiv" style="width:65%">
    <h2 class="formTitle">User Master</h2>
    <h1 class="formError" style="text-align:right;font-size:smaller;color:#CC2900;">Fields marked with * are mandatory</h1>
	<%--<span id="mandatoryMessage" class="formError">Fields marked with * are mandatory</span>--%>
    <table cellspacing="1" cellpadding="1" border="0" width="100%">
        
       
        <tr>
            <td align="right">
                User ID<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtUserId" runat="server" MaxLength="10" TabIndex="2"></asp:TextBox>
                <%--<asp:Button ID="bntbrowse" runat="server" Text="..." Width="25px"   
                    OnClick="bntbrowse_Click" CausesValidation="False" TabIndex="3" />
                <asp:Button ID="bntgetdetails" runat="server" Text="Get Details" 
                    OnClick="bntgetdetails_Click" CausesValidation="False" 
                    OnClientClick="javascript:return SelectUser();" TabIndex="4" />--%>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ErrorMessage="User Id is Mandatory" CssClass="formError"
                    ControlToValidate="txtUserId" InitialValue="" 
                    SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regUserId" runat="server" 
                    ControlToValidate="txtUserId" CssClass="formError"
                    ErrorMessage="Invalid Userid" ValidationExpression="^[0-9a-zA-Z]+$" 
                    SetFocusOnError="True"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                User Type<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:DropDownList ID="ddlUserType" runat="server" AutoPostBack="True" 
                    TabIndex="5" Width="170px" OnSelectedIndexChanged="ddlUserType_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="reqUserType" runat="server" 
                    ErrorMessage="User Type is Mandatory" CssClass="formError"
                    ControlToValidate="ddlUserType" InitialValue="0" 
                    SetFocusOnError="True"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                Remitter Code
            </td>
            <td>
                <input id="txtRemitterId" style="width: 125px" type="text" 
                    runat="server" enableviewstate="false"  readonly="readonly" />
                <asp:Button ID="bntbrowseRemitter" runat="server" Text="..." Width="25px"   OnClick="bntbrowseRemitter_Click" CausesValidation="False" />
            </td>
            <td align="left">
                Customer Name 
            </td>
            <td align="left">
                <asp:Label ID="lblCustmerName" runat="server" CssClass="lable" ForeColor="#ff8400"/>
               <%-- <asp:TextBox ID="txtCustomerId" runat="server" MaxLength="10" TabIndex="7"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqCustomerId" runat="server" 
                    ErrorMessage="Customer Id is Mandatory" CssClass="formError"
                    ControlToValidate="txtCustomerId" InitialValue="" 
                    SetFocusOnError="True"></asp:RequiredFieldValidator>--%>
            </td>
        </tr>
        <%--<tr>
            <td align="right">
                Customer ID<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtCustomerId" runat="server" MaxLength="10"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqCustomerId" runat="server" 
                    ErrorMessage="Customer Id is Mandatory" CssClass="formError"
                    ControlToValidate="txtCustomerId" InitialValue="" 
                    SetFocusOnError="True"></asp:RequiredFieldValidator>
            </td>
        </tr>--%>
        <tr>
            <td align="right">
                User Name<span style="color: #ff0000">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtUserName" runat="server" MaxLength="35" TabIndex="8"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqUserName" runat="server" 
                    ErrorMessage="User Name is Mandatory" CssClass="formError"
                    ControlToValidate="txtUserName" InitialValue="" 
                    SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regUserName" runat="server" 
                    ControlToValidate="txtUserName" CssClass="formError"
                    ErrorMessage="Invalid User Name" 
                    ValidationExpression="^[a-zA-Z''-'\s]{1,50}$" SetFocusOnError="True"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <%--<tr>
            <td align="right">
                Password: <span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" MaxLength="50" 
                    TabIndex="9"></asp:TextBox>
                <asp:RegularExpressionValidator ID="regPassword" runat="server" 
                    ControlToValidate="txtPassword" CssClass="formError"
                    ErrorMessage="Password must starts with alphabets followed by atleast one digit "
                    SetFocusOnError="True" 
                    ValidationExpression="^([a-zA-Z]+)[0-9]+[a-zA-Z0-9]*"></asp:RegularExpressionValidator>
            </td>
        </tr>--%>
        <tr>
            <td align="right">
                Email Id<span style="color: #ff0000">*</span>
            </td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server" MaxLength="50" TabIndex="10"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqEmail" runat="server" 
                    ControlToValidate="txtEmail" CssClass="formError"
                    ErrorMessage="Enter Email ID" SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regEmail" runat="server" 
                    ControlToValidate="txtEmail" CssClass="formError"
                    ErrorMessage="Enter Correct Email Id" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                    SetFocusOnError="True"></asp:RegularExpressionValidator>
            </td>
            <td align="left">
                Mobile No.
            </td>
            <td align="left">
                <asp:TextBox ID="txtMobileNumber" runat="server" MaxLength="15" TabIndex="11"></asp:TextBox>&nbsp;
                <asp:RegularExpressionValidator ID="regMobileNo" runat="server" 
                    ControlToValidate="txtMobileNumber" CssClass="formError"
                    ErrorMessage="Invalid Mobile Number" ValidationExpression="[0-9]*" 
                    SetFocusOnError="True"></asp:RegularExpressionValidator>
            </td>
        </tr>
       <%-- <tr>
            <td align="right">
                Mobile Number
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtMobileNumber" runat="server" MaxLength="15"></asp:TextBox>&nbsp;
                <asp:RegularExpressionValidator ID="regMobileNo" runat="server" 
                    ControlToValidate="txtMobileNumber" CssClass="formError"
                    ErrorMessage="Invalid Mobile Number" ValidationExpression="[0-9]*" 
                    SetFocusOnError="True"></asp:RegularExpressionValidator>
            </td>
        </tr>--%>
        <tr>
            <td align="right">                
            </td>
            <td>
                <asp:CheckBox ID="chkEnable" runat="server" Text="Enable" Checked="True" 
                    TabIndex="12" />&nbsp;
                &nbsp;&nbsp; <asp:CheckBox ID="chkLock" runat="server" Text="Lock" 
                    TabIndex="13" />&nbsp;
                <%--&nbsp;&nbsp; <asp:CheckBox ID="chkActive" runat="server" Text="Active" 
                    Checked="True" TabIndex="14" />--%>
            </td>
        </tr>      
        <tr>
            <td align="right">
            </td>
            <td colspan="3">
                <asp:Button ID="btnSubmit" runat="server" Text="Add" 
                    OnClick="btnSubmit_Click" TabIndex="15" />
                <asp:Button ID="btnCancel" runat="server" Text="Reset" CausesValidation="False" 
                    OnClick="btnCancel_Click" TabIndex="16" UseSubmitBehavior="False" />
            </td>
        </tr>
    </table>


            <div style="height:140px; width:100%; overflow:auto;">
                <asp:GridView ID="gvCustomer" runat="server" AllowPaging="false" 
                        AutoGenerateColumns="False" Width="100%"
                        HeaderStyle-BackColor="silver" HeaderStyle-ForeColor="#6f788f" 
                            HeaderStyle-Font-Bold="false" OnRowDeleting="gvCustAccount_RowDeleting">
                    <EmptyDataTemplate>
                        <asp:Label ID="lblNoRows" runat="server" Text="No records found for customer account detail." />
                    </EmptyDataTemplate>
                    <Columns>
                        <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:LinkButton  ID = "lnkSelect" runat="server"  Text = "Select"  CausesValidation="false" CommandName="Select"></asp:LinkButton>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="User ID" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblUserID" runat="server" Text='<%# Eval("UserID") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="User Type" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblUserType" runat="server" Text='<%# Eval("UserType") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Role ID" ItemStyle-HorizontalAlign="Center" >
                            <ItemTemplate>
                                <asp:Label ID = "lblRoleID" runat="server"  Text='<%# Eval("RoleID") %>' />
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Remitter Code" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblRemitterID" runat="server" Text='<%# Eval("RemitterID") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="User Name" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblUserName" runat="server" Text='<%# Eval("UserName") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                         <asp:TemplateField HeaderText="Email" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblEmailAddress" runat="server" Text='<%# Eval("EmailAddress") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                         <asp:TemplateField HeaderText="Mobile" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblMobileNumber" runat="server" Text='<%# Eval("MobileNumber") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                         <asp:TemplateField HeaderText="Enabled?" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblIsEnabled" runat="server"  Text='<%# Eval("IsEnabled") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                         <asp:TemplateField HeaderText="Is Locked?" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblIsLocked" runat="server" Text='<%# Eval("IsLocked") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ItemStyle-HorizontalAlign="Center"/>
                        
                    </Columns>
                </asp:GridView>
                </div>
    <asp:UpdatePanel ID="upUnmatchedLists" runat="server" UpdateMode="Conditional">
        <ContentTemplate>    
                <div id="pnlMatchList" runat="server" class="pnlMatchList">    
                    <span style="azimuth: center;">
                        <div id="Div1" class="formDiv" runat ="server"  >
                            <center>
                                <asp:Label ID="lblMessage" runat="server"    CssClass="lable"/>
                            </center>
                        </div>
                    </span>
                    <div class="formDiv" style="width: 30%;">
                         <center>
                            <asp:Button ID="btnok" runat="server" Text="OK" onclick="btnok_Click" CausesValidation="False"  />
                          </center>
                    </div>
                </div>
            <div style="display: none">
                <asp:Button ID="btnManualPopup" runat="server" />
            </div>
            <ajax:ModalPopupExtender ID="btnClickPopup" runat="server" PopupControlID="pnlMatchList"
                TargetControlID="btnManualPopup" BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowScroll" OkControlID = "btnok">
            </ajax:ModalPopupExtender>   
        </ContentTemplate>        
    </asp:UpdatePanel>
    </div>


     <script type="text/javascript">
         $(function () {
             
             $("[id*=lnkSelect]").click(function () {
                 var tr = $(this).closest('tr');
                 //alert($(this).closest('tr').find('span[id*="lnkSelect"]').attr('Text'));
                 var UserID = $(tr).find('span[id*="lblUserID"]').text();
                 var UserType = $(tr).find('span[id*="lblUserType"]').text();
                 var roleId = $(tr).find('span[id*="lblRoleID"]').text();
                 var RemitterID = $(tr).find('span[id*="lblRemitterID"]').text();
                 var UserName = $(tr).find('span[id*="lblUserName"]').text();
                 var EmailAddress = $(tr).find('span[id*="lblEmailAddress"]').text();
                 var MobileNumber = $(tr).find('span[id*="lblMobileNumber"]').text();
                 var isEnable = $(tr).find('span[id*="lblIsEnabled"]').text();
                 var isLocked = $(tr).find('span[id*="lblIsLocked"]').text();
                 
                 
                 var usertypevalue = UserType.concat("-").toString();//  + "-" + roleId1.toString()
                 //alert(roleId);
                 //alert(usertypevalue);
                 //var usertypeconcatvalue = usertypevalue.concat(roleId);
                 usertypevalue = usertypevalue + roleId.toString();
                 //alert(usertypevalue);
                 //var usertypeconcatvalue = $(new String(usertypevalue)) + $(new String(roleId));
                 
                 //alert(usertypeconcatvalue);

                 $("#<%= txtUserId.ClientID %>").val(UserID).text();
                 $("#<%= ddlUserType.ClientID %>").val(usertypevalue).text();
                $("#<%= txtRemitterId.ClientID %>").val(RemitterID).text();
                $("#<%= txtUserName.ClientID %>").val(UserName).text();
                 $("#<%= txtEmail.ClientID %>").val(EmailAddress).text();
                 $("#<%= txtMobileNumber.ClientID %>").val(MobileNumber).text();

                 var btntext = "Modify";
                 $("#<%= btnSubmit.ClientID %>").val(btntext).text();

                if (isEnable.toString() == "True") {
                    $("#<%= chkEnable.ClientID %>").prop('checked', true);
                        }
                else { $("#<%= chkEnable.ClientID %>").prop('checked', false); }

                 if (isLocked.toString() == "True") {
                     $("#<%= chkLock.ClientID %>").prop('checked', true);
                 }
                 else { $("#<%= chkLock.ClientID %>").prop('checked', false); }

                return false;
            });
         });


         function SelectUser() {
             var Username = document.getElementById('<%=txtUserId.ClientID %>').value;
             if (Username == '') {
                 alert("User Id is Mandatory");
                 return false;
             }

             return true;
         }
    </script>
</asp:Content>
